﻿#include "appearance.h"
#include <QFile>
#include <QTranslator>

bool Appearance::LoadStyle(QApplication *app,QString qss_file)
{
    QFile file(qss_file);
    if(!file.open(QFile::ReadOnly)){
        throw ("Open qss file failed.");
        return false;
    }

    QString styleSheet = QLatin1String(file.readAll());
    app->setStyleSheet(styleSheet);
    return true;
}

bool Appearance::LoadTranslate(QApplication *app, QString trans_file)
{
    auto translator = new QTranslator;
    if(!translator->load(trans_file)){
        throw("Load translate file failed.");
        return false;
    }

    if(!app->installTranslator(translator)){
        throw("Apply translate file failed.");
        return false;
    }

    app->processEvents();
    return true;
}

